<?php
//Pixel Gaming Pickup Bot
//Pickup Server List

//TF2 Server Class

chdir("SteamCondenser/lib");
include_once("steam/servers/SourceServer.php");
chdir("../../");

class server
{
	public $server;
	public $host;
    public $port;
	public $rconpass;
	public $connect;

    public function init($host, $port, $rconpass)
    {
        $this->host = $host;
        $this->port = $port;
        $this->rconpass = $rconpass;
        
        //Create connect command
		$this->connect = "connect ".$host.":".$port." ; password pixelpickup";
    }
    
    public function is_empty()
    {
        $serverIp = new InetAddress($this->host);
		$server = new SourceServer($serverIp, $this->port);
		
		//Get player count
		$playercount = count($server->getPlayers());
		
	    //Find out if a server is empty
		if($playercount > 1)
		{
			$returnvalue = false;
		} else
		{
			$returnvalue = true;
		}

		//Return the value
		return $returnvalue;
    }
    
    public function changelevel($map)
    {
    	$serverIp = new InetAddress($this->host);
		$server = new SourceServer($serverIp, $this->port);
		
		$server->rconAuth($this->rconpass);
		$server->rconExec("changelevel ".$map);
    }
    
    public function rcon($command)
    {
    	$serverIp = new InetAddress($this->host);
		$server = new SourceServer($serverIp, $this->port);
    
    	$server->rconAuth($this->rconpass);
		$server->rconExec($command);
    }
}


//Create servers and give info
$servers[1] = new server;
$servers[1]->init("109.236.80.230", "27080", "rconpasshere");

$servers[2] = new server;
$servers[2]->init("109.236.80.230", "27085", "rconpasshere");

$servers[3] = new server;
$servers[3]->init("109.236.80.230", "27090", "rconpasshere");

$servers[4] = new server;
$servers[4]->init("109.236.80.230", "27095", "rconpasshere");
?>
